<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>

<head>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">


	<title> - 登录</title>
	<meta name="keywords" content="">
	<meta name="description" content="">

	<link rel="shortcut icon" href="favicon.ico"> <link href="${pageContext.request.contextPath}/res/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/res/css/font-awesome.css?v=4.4.0" rel="stylesheet">

	<link href="${pageContext.request.contextPath}/res/css/animate.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/res/css/style.css?v=4.1.0" rel="stylesheet">
	<!--[if lt IE 9]>
	<meta http-equiv="refresh" content="0;ie.html" />
	<![endif]-->
	<script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
	<div>
		<div>

			<h1 class="logo-name">h</h1>

		</div>
		<h3>欢迎使用 </h3>

		<form class="m-t" role="form" action="${pageContext.request.contextPath}/login.do">
			<div class="form-group">
				<input type="" class="form-control" placeholder="用户名" id="username">
			</div>
			<div class="form-group">
				<input type="password" class="form-control" placeholder="密码" id="password">
			</div>
			<button type="button" onclick="login();" class="btn btn-primary block full-width m-b">登 录</button>

			<p class="text-muted text-center"> <a href="login.jsp#"><small>忘记密码了？</small></a> | <a href="register.jsp">注册一个新账号</a>
			</p>

		</form>
	</div>
</div>

<!-- 全局js -->
<script src="${pageContext.request.contextPath}/res/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/res/js/bootstrap.min.js?v=3.3.6"></script>
<script>
    function login() {
        var name = $("#username").val();
        var password = $("#password").val();
        if(name==""||password==""){
            alert("请输入账号和密码");
        }
        $.ajax({
            type: "post",
            url: "${pageContext.request.contextPath}/login.do",
            data: {"name":name,"password":password},
            dataType: "json",
            success:function(data) {
                console.log(data);
                if(data.status==1){
                    location.href="${pageContext.request.contextPath}/manager/index.do";
                }else{
                    alert("账号或密码错误");
                }
            }
        });
    }

</script>
</body>

</html>
